package org.budo.support.jsoup;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

/**
 * @author lmw
 */
public class JsoupUtil {
    public static String removeStyle(String html) {
        if (null == html || html.trim().isEmpty()) {
            return html;
        }

        Document document = Jsoup.parse(html);
        document.select("style").remove();
        return document.toString();
    }

    public static String removeScript(String html) {
        if (null == html || html.trim().isEmpty()) {
            return html;
        }

        Document document = Jsoup.parse(html);
        document.select("script").remove();
        return document.toString();
    }

    public static String text(String html) {
        if (null == html || html.trim().isEmpty()) {
            return html;
        }

        Document document = Jsoup.parse(html);
        return document.text();
    }
}